${page.setTitle("push-center| GOPS")}
<style type="text/css">
    .l-table-edit {}
    .l-table-edit-td{ padding:4px;}
    .l-button-submit,.l-button-reset{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
</style>
${token()}
<div class="body-pla-content">
  <form action="" method="post" id="template" name="template">
        <table class="l-table-edit" >
            <tr>
                <td align="right" >所属模板：</td>
                <td align="left" >
                	<input type="text" name="templateId" id="templateId" readonly="true"/>
				</td>
				
                <td align="right" >所属域：</td>
                <td align="left" >
                	<input type="text" name="domainId" id="domainId" />
				</td>
				
			 </tr> 
			  <tr>
			  	<td align="right" >appId：</td>
                <td align="left" >
                	<input type="text" name="appId" id="appId" readonly="true"  placeholder="必须先选域"/>
                	<input type="hidden" name="appChannelId" id="appChannelId" />
				</td>
				
                <td align="right" >外部模板id：</td>
                <td align="left" >
						<input name="extTemplId" type="text" id="extTemplId"  maxlength="100" value="" placeholder="微信,email等渠道必填..." validate="{required:true,maxlength:30}"/>
				</td>
				
			 </tr>
			  <tr>
                <td align="right" >应用模版名：</td>
                <td align="left" >
						<input name="name" type="text" id="name"  maxlength="100" value=""  validate="{required:true,maxlength:30}"/>
				</td>
                <td align="right" >应用模版优先级：</td>
                <td align="left" >
						<input name="priority" type="text" id="priority"  maxlength="100" value="" placeholder="必填..." validate="{required:true,maxlength:30}"/>
				</td>
				
			 </tr>
			 
			  <tr>
                <td align="right" >对应关系：</td>
                <td align="left" colspan=3>
					 <textarea rows="3" cols="60" name="paramConvert" id="paramConvert" placeholder="模版的参数(例如:a,b要转成渠道方接口对应的参数a2,b2 格式如下: a,a2;b,b2)" ></textarea>
				</td>
			 </tr> 
			 
			  <tr>
                <td align="right" >模板：</td>
                <td align="left" colspan=3>
					 <textarea rows="3" cols="60" name="text" id="text" placeholder="如果配置这个地方,则推送的时候使用这个模板，而不使用默认模板..."></textarea>
				</td>
			 </tr> 
			 
             <tr>
				 <td align="right" >备注：</td>
                <td align="left" colspan=3>
                <textarea rows="3" cols="60" name="memo" id="memo" ></textarea>
				</td>
            </tr>  
            <tr>
            	<td></td>
            	<td colspan=3> <input type="button" value="新增" id="dosubmit" class="l-button l-button-submit"/>  </td>
            	<td align="left"></td>
            </tr>
        </table>
    </form>
</div>



 

 
<script type="text/javascript">

$(function () {
	epay_enum.iniSelect();
	$("#dosubmit").click(function(){
		var queryString = $('#template').serializeArray(); 
	    $.ajax({
	        url: "${appServer}/apptemplate/add.json",   
	        data: queryString, 
	        type: "POST",
	        success: function(result) {
	        	if(result.hasError) {
					$.ligerDialog.error(result.message);
	        	}else{
	        		$.ligerDialog.success(result.message);
	        		parent.window.search();
	        		parent.$.ligerDialog.close();
	        		parent.$.ligerDialog.hide();
	        	}
	        }
	    });	
		return true;
	});


	 //-------------------template ----------------------
	 
	  $(function ()
        { 
            $("#templateId").ligerComboBox({
                onBeforeOpen: f_selectContact,width:135
            });
        });
        function f_selectContact()
        {
            $.ligerDialog.open({ title: ' ++选择模板_ID', name:'winselector',width: 550, height: 400,  url: '${appServer}/template/list-alltemplate', buttons: [
                { text: '确定', onclick: f_selectContactOK },
                { text: '取消', onclick: f_selectContactCancel }
            ]
            });
            return false;
        }
        function f_selectContactOK(item, dialog)
        {
			var fn = dialog.frame.f_select || dialog.frame.window.f_select; 
            var data = fn(); 
            if (!data)
            {
                alert('请选择行!');
                return;
            }
            $("#templateId").val(data.id);
            dialog.close();
        }
        function f_selectContactCancel(item, dialog)
        {
            dialog.close();
        }
	 //-------------------tempate end!!!----------------


//-----------------appid-start----------------------------------

 $(function ()
        { 
            $("#appId").ligerComboBox({
            	
                onBeforeOpen: f_selectContact2, width:135
            });
        });
        function f_selectContact2()
        {
        //如果domain不存在,直接反回
         var domainid=	$("#domainId").val();
		        if(!domainid){
		        	return;
		        }
            $.ligerDialog.open({ title: ' ++选择APP_ID', name:'winselector',width: 550, height: 400,  url: '${appServer}/domainappchannel/listall-domainchannel/'+domainid, buttons: [
                { text: '确定', onclick: f_selectContactOK2 },
                { text: '取消', onclick: f_selectContactCancel2 }
            ]
            });
            return false;
        }
        function f_selectContactOK2(item, dialog)
        {
			var fn = dialog.frame.f_select || dialog.frame.window.f_select; 
            var data = fn(); 
            if (!data)
            {
                alert('请选择行!');
                return;
            }
            $("#appId").val(data.appId);
            $("#appChannelId").val(data.appChannelId);
            dialog.close();
        }
        function f_selectContactCancel2(item, dialog)
        {
            dialog.close();
        }
        
        
//-----------------appid-end----------------------------------

//-----------------domain_start -----------
 $(function ()
        { 
            $("#domainId").ligerComboBox({
                onBeforeOpen: f_selectContact3, width:135
            });
        });
        function f_selectContact3()
        {
            $.ligerDialog.open({ title: ' ++选择域', name:'winselector',width: 550, height: 400,  url: '${appServer}/domain/listall-domain', buttons: [
                { text: '确定', onclick: f_selectContactOK3 },
                { text: '取消', onclick: f_selectContactCancel3 }
            ]
            });
            return false;
        }
        function f_selectContactOK3(item, dialog)
        {
			var fn = dialog.frame.f_select || dialog.frame.window.f_select; 
            var data = fn(); 
            if (!data)
            {
                alert('请选择行!');
                return;
            }
            $("#domainId").val(data.id);
            dialog.close();
        }
        function f_selectContactCancel3(item, dialog)
        {
            dialog.close();
        }
	
	
	//------------------------domain---------end
});



</script>